home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / workbench / versionwb / dopusscript / versioncopy.dopus < prev   
Text File  |  2000-02-28  |  3KB  |  88 lines

  1. /* $VER: VersionCopy.DOpus V1.0 (30-Jun-96) Allan Odgaard
  2.    Please send an email to <Duff@DIKU.DK> if you use it.
  3.    Also check out <http://www.DIKU.dk/students/duff/>
  4.  
  5. Intro:
  6. ¯¯¯¯¯¯
  7. This script works with DOpus 4.x, its purpose is to show versioninfo for the
  8. selected file and the one with the same name in the destination lister. And
  9. based upon this, the user can select wether (s)he wants to replace the
  10. file or not.
  11.  
  12. When you choose to replace a file, then this script will make sure that the
  13. comment and name of the old file are intact. This means that if your
  14. diskfontlib is named DiskFont.Library and commented to "Workbench 3.1", then
  15. if you copy in a new diskfont.library which is strictly in lower case and has
  16. no comment, the this new file will inherit the olds comment and case usage.
  17.  
  18. Install:
  19. ¯¯¯¯¯¯¯¯
  20. Action: DoubleClick or Click-m-click.
  21. AmigaDOS: Rexx:DirectoryOpus/VersionCopy.DOpus {o} {Qp}
  22. \ Run asynchronously
  23.  
  24. Action: Button, Menu or Hotkey.
  25. ARexx: Rexx:DirectoryOpus/VersionCopy.DOpus
  26.  
  27.  */
  28.  
  29. Options Results
  30.  
  31. Parse Arg '"' File '"' PortName .
  32. If PortName ~= '' Then Address(PortName)
  33.  
  34. /* Trace Results */
  35.  
  36. LF = '0a'x
  37.  
  38. Status 3        ; ActWin = Result
  39. Status 13 ActWin    ; SrcDir = Result
  40. Status 13 1-ActWin    ; DestDir = Result
  41. Status 27        ; OldCancel = Result
  42. Status 27 Set "Skip"
  43.  
  44. Busy On
  45.  
  46. If File = '' Then Signal ProgramStart
  47. Call HandleFile
  48.  
  49. End:        Status 27 Set OldCancel
  50.         Address Command "C:Delete T:Version.#? Quiet"
  51.         Busy Off
  52.         ReScan 1-ActWin
  53.         Exit
  54.  
  55. ProgramStart:    GetNextSelected        ; File = Result
  56.         If File="0" Then Signal End
  57.         Call HandleFile
  58.         Signal ProgramStart
  59.  
  60. HandleFile:    SelectFile File 0 1
  61.         If ~Exists(DestDir || File) Then Do ; Copy File ; Return ; End
  62.  
  63.         Address Command 'C:VersionWB "'SrcDir || File'" Text >T:Version.Tmp'
  64.         Call ExtractVer        ; NewFile = Result
  65.  
  66.         Address Command 'C:VersionWB "'DestDir || File'" Text >T:Version.Tmp'
  67.         Call ExtractVer        ; OldFile = Result
  68.  
  69. AskUser:    Request    "`"File"'"LF || LF"New files version:" NewFile || LF || "Old files version:" OldFile || LF || LF"Would you like to replace the file?"
  70.         If Result=0 Then Return
  71.         Address Command 'C:FileNote "'SrcDir || File'" "`C:List "'DestDir || File'" LFormat %c`"'
  72.         Address Command 'C:Copy >T:Version.Copy "'SrcDir || File'" "'DestDir'`C:List "'DestDir'" Pat="('File'|%)" LFormat %n`" Clone'
  73.         If RC ~= 0 Then Do
  74.         Open('Error','T:Version.Copy','Read') ; Request ReadLn('Error') ; Close('Error')
  75.         End
  76.         Return
  77.  
  78. ExtractVer:    Open('VerOut','T:Version.Tmp','Read')
  79. SearchLoop:    If EOF('VerOut') Then Do
  80.         Close('VerOut')
  81.         Return('Unknown')
  82.         End
  83.         VerTmp = ReadLn('VerOut')
  84.         If Left(VerTmp,9) ~= "Version: " Then Signal SearchLoop
  85. FoundVer:    Version = Right(VerTmp,Length(VerTmp)-9)
  86.         Close('VerOut')
  87.         Return(Version)
  88.